# -*- coding: utf-8 -*-
# @Author: Tim Liu
# @Date: 2024-05-27
# @Last Modified by: Tim Liu
# @Last Modified time: 2024-05-27

# @Description: Knowledge Base Schemas for RAG

from pydantic import BaseModel, Field, ConfigDict
from core.data_types import DatetimeStr
from apps.vadmin.auth.schemas import UserSimpleOut


class KnowledgeBase(BaseModel):
    """A Knowledge Base is a collection of Documents for certain domain. 
        It has a unique knowledge base id, and one knowledge base can contain many Documents (with unique doc id, and source url).  

    Args:
        name: knowledge base unique name 
        description: knowledge base description
        is_active: knowledge base active flag
        create_user_id: knowledge base creator id
    """    
    name: str | None = None
    description: str | None = None
    is_active: bool | None = None
    create_user_id: int | None = None

    # BEGIN-ADD: return colletion information, steven, 2025-01-06
    coll_id: int | None = None
    coll_name: str | None = None
    # END-ADD


class KnowledgeBaseSimpleOut(KnowledgeBase):
    model_config = ConfigDict(from_attributes=True)

    id: int
    name: str
    update_datetime: DatetimeStr
    create_datetime: DatetimeStr


class KnowledgeBaseListOut(KnowledgeBaseSimpleOut):
    model_config = ConfigDict(from_attributes=True)

    create_user: UserSimpleOut


class KnowledgeBaseOptionsOut(BaseModel):
    model_config = ConfigDict(from_attributes=True)

    label: str = Field(alias='name')
    value: int = Field(alias='id')

